package com.blog.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.blog.entity.User;
import com.blog.service.UserService;
import com.blog.service.Impl.UserServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;

@WebServlet("/delUserCheck.do")
public class DeleteUserCheckServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int userId =request.getParameter("userId") == null ? 1: Integer.parseInt(request.getParameter("userId"));
		UserService us = new UserServiceImpl();
		response.setContentType("application/json;charset=utf-8");
		User user=new User();
		user.setUserId(userId);
		new ObjectMapper().writeValue(response.getWriter(), us.insterUser(user));
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
